package com.itheima.wemedia.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.mededia.pojo.WmNews;
import com.heima.model.common.mededia.pojo.WmUser;
import com.itheima.wemedia.service.WMUserService;
import com.itheima.wemedia.service.WnNewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "自媒体用户API",tags = "自媒体用户API")
@RestController
@RequestMapping("/api/v1/user")
public class WemediaController {
    @Autowired
    private WMUserService wmUserService;
    @ApiOperation("保存自媒体用户信息")
    @PostMapping("save")
    public ResponseResult<WmUser> sava(@RequestBody WmUser wmUser){
        wmUserService.save(wmUser);
        return ResponseResult.okResult(wmUser);

    }
    @ApiOperation("根据名称查询自媒体用户信息")
    @GetMapping("/findByName/{name}")
    public ResponseResult<WmUser> findByName(@PathVariable("name") String name){
        WmUser one = wmUserService.getOne(Wrappers.<WmUser>lambdaQuery().eq(WmUser::getName, name));
        return ResponseResult.okResult(one);
    }



}
